<?php

namespace QF;

class System {
    
    static public $table = 'system';
    
    public function getAll() {
        $result = Db()->getAll(static::$table)->result();
        foreach ($result as &$item) {
            $value = $item['value'] ? $item['value'] : null;
            $item['value'] = MDecode($value);
        }
        return $result;
    }
    
    public function setOne($name, $value) {
        $where = array('name' => $name);
        $arrSets = array('value' => MEncode($value));
        $result = Db()->update(static::$table, $arrSets, $where);
        return $result;
    }
    
    public function getValue($name) {
        $where = array('name' => $name);
        $result = Db()->getOne(static::$table)->fields('value')->where($where)->result();
        return MDecode($result);
    }
    
}
